<?php
class Form_ChangePasswd extends QForm
{
	function __construct($action)
	{
		parent::__construct('form_changepasswd', $action);
		
		$filename = rtrim(dirname(__FILE__) , '/\\') . DS . 'changepasswd_form.yaml.php';
		$this->loadFromConfig(Helper_YAML::loadCached($filename));
		
		$this['old_password']->addValidations(User::meta(), 'password');
		$this['new_password']->addValidations(User::meta(), 'password');
		$this['new_password2']->addValidations(User::meta(), 'password')
		->addValidations(array($this, 'checkNewPassword'), '两次输入的密码必须一致');
	}
	function checkNewPassword()
	{
		return ($this['new_password2']->value == $this['new_password']->value);
	}
}